<?php

// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: create by allen.qiang
// +----------------------------------------------------------------------

/**
 * 生产查询
 * @package  htdocs
 * @subpackage  quanliadmin
 * @author   create by allen.qiang
 */

//引入字典类
quanli_require('module/base/system/itemHandler.class.php');

class pa_productionSearch {

    public function execute() {

        if (isset($_REQUEST['operFlg']) && quanli_is_int($_REQUEST['operFlg'])) {

            switch ($_REQUEST['operFlg']) {

                case 1: //显示列表页面
                    $this->productionSearchList();
                    break;

                default:
                    backendError();
                    break;
            }

        } else {
            backendError();
        }

    }


    /**
     * 显示列表页面
     */
    private function productionSearchList() {

        global $G_PGLOB;

        //实例化字典类
        $itemHandler = new itemHandler();

        //配送开始时间数组
        $sendStartTime_array = array();

        //配送结束时间数组
        $sendEndTime_array = array();

        //配送时间参数
        $itemStart_array = array(
            'useFlg' => 1,
            'sortname' => 'itemID',
            'sortorder' => 'ASC'
        );

        //查询字典表信息
        $temp_array = $itemHandler->searchItem( $itemStart_array );

        if( $temp_array ){
            foreach( $temp_array as $val ){
                if($val['itemCategoryID'] == 9){
                    $sendStartTime_array[]['itemName'] = $val['itemName'];
                }

                if($val['itemCategoryID'] == 10){
                    $sendEndTime_array[]['itemName'] = $val['itemName'];
                }

            }
        }

        $G_PGLOB->smarty->assign_by_ref('sendStartTime_array',$sendStartTime_array);//配送开始时间
        $G_PGLOB->smarty->assign_by_ref('sendEndTime_array',$sendEndTime_array);//配送结束时间
        $G_PGLOB->smarty->assign('date',$G_PGLOB->sys_date);//配送结束时间
        $G_PGLOB->smarty->assign('edit_permission', $G_PGLOB->has_permission(20000));

        $table_id = 6;

        $flex_array = array(
            array('display' => '<input type="checkbox" id="allChecked" />','width' => 60,'align' => 'center'),
            array('display' => '序号', 'width' => 60, 'align' => 'center'),
            array('display' => '城市', 'width' => 90, 'align' => 'left'),
            array('display' => '订单标识','width' => 80, 'align' => 'left'),
            array('display' => '订单状态','width' => 90, 'align' => 'left'),
            array('display' => '订单类型','width' => 90, 'align' => 'left'),
            array('display' => '配送日期','width' => 90, 'align' => 'center'),
            array('display' => '配送开始时间','width' => 90,'align' => 'center'),
            array('display' => '配送结束时间','width' => 90,'align' => 'center'),
            array('display' => '下单时间','width' => 140,'align' => 'center'),
            array('display' => '打印次数','width' => 70,'align' => 'center'),
            array('display' => '打印时间','name'=> 'print_time','sortable'=>true,'width' => 140,'align' => 'center'),
            array('display' => '订单编号','width' => 140,'align'=>'center'),
            array('display' => '配送站','width' => 120,'align'=>'left'),
            array('display' => '商品编号','name' => 'product_code','sortable'=>true,'width' => 180,'align'=>'left'),
            array('display' => '商品名称','width' => 280,'align'=>'left'),
            array('display' => '规格','name'=>'goods_spec','sortable'=>true,'width' => 240,'align'=>'left'),
            array('display' => '商品数量','width' => 60,'align'=>'left'),
            array('display' => '餐具数量','width' => 60,'align'=>'left'),
            array('display' => '生日牌','width' => 180,'align'=>'left'),
            array('display' => '切分','width' => 60,'align'=>'left'),
            array('display' => '生产要求','width' => 200,'align'=>'left'),
        ); //flexigrid插件表格  end

        quanli_require('module/base/system/sysFlexigridLog.class.php');

        $sysFlexigridLog = new sysFlexigridLog();

        $arg_array = array(
            'table_id' => $table_id,
            'userID' => $G_PGLOB->currentUserID,
            'sortname' => 'last_cid',
            'sortorder' => 'ASC'
        );
        $flexigrid_array = $sysFlexigridLog->searchFlexigridInfo($arg_array);

        if($flexigrid_array){
            $flex_array = $flexigrid_array;
        }else{
            $arg_array = array(
                'table_id' => $table_id,
                'userID' => $G_PGLOB->currentUserID,
                'data' => $flex_array
            );
            $sysFlexigridLog->editFlexigrid($arg_array);
        }

        $G_PGLOB->smarty->assign_by_ref('table_id', $table_id);
        $G_PGLOB->smarty->assign_by_ref('fixed_json', json_encode($flex_array));

        $G_PGLOB->smarty->display('production/productionSearch.tpl');

    }

}
